﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Projeto__A_Cura.Scenes
{
    class Scene01 : BaseScene
    {
        //SoundEffect test;

        public Scene01(SceneManager.Scenes thisScene)
            : base(thisScene) { }

        public override void LoadContent(ContentManager Content)
        {
            audio01 = Content.Load<Song>(contentDir + "Menu");
            //test = Content.Load<SoundEffect>();
            description = "Menu";
        }

        public override void Update(
            KeyboardState keyboard,
            KeyboardState old_keyboard,
            GameTime gameTime,
            SceneManager.Scenes actualScene)
        {
            //keyboard = Keyboard.GetState();

            //if (actualScene == SceneManager.Scenes.SCENE01)
            //{
            //test.Play(1.0f, 0.0f, 0.0f);

            if (!wasAudio01Played)
            {
                MediaPlayer.Play(audio01);
                wasAudio01Played = true;
            }

            //TO DO só pode tocar uma vez, então pára e ... ?
            //conta um tempo, e toca de novo as instruções finais, inclusive o repeat...
            //TO DO pular... só qd já tocou tudo ?

            if ((MediaPlayer.State == MediaState.Stopped)
                || (SceneManager.DEBUG))
            {
                if (keyboard.IsKeyDown(Keys.Space) && !old_keyboard.IsKeyDown(Keys.Space))//repetir... "áudio de fita retrocedendo"?
                {
                    wasAudio01Played = false;
                    //SceneManager.lastScene = actualScene;
                    SceneManager.actualScene = thisScene;
                }

                if (keyboard.IsKeyDown(Keys.Up) && !old_keyboard.IsKeyDown(Keys.Up))//começar
                {
                    wasAudio01Played = false;
                    SceneManager.lastScene = thisScene;
                    SceneManager.actualScene = SceneManager.Scenes.SCENE02;
                }

                if (keyboard.IsKeyDown(Keys.Right) && !old_keyboard.IsKeyDown(Keys.Right))//créditos
                {
                    wasAudio01Played = false;
                    SceneManager.lastScene = thisScene;
                    SceneManager.actualScene = SceneManager.Scenes.SCENE03;
                }

                if (keyboard.IsKeyDown(Keys.Left) && !old_keyboard.IsKeyDown(Keys.Left))//instruções/tutorial
                {
                    wasAudio01Played = false;
                    SceneManager.lastScene = thisScene;
                    SceneManager.actualScene = SceneManager.Scenes.SCENE04;
                }
            }
        }

        //old_keyboard = keyboard;

        //o grande lance é saber pra onde ir...
        //declaracao dos estados todos no sm...
        //criacao das classes objetos em g1...
        //preenchimento dos metodos de load e update dentro delas...
        //só...
    }

}
